package sphere;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

public class SphereSecondTry {

	private static double volume(double r) {
		return 4.0 / 3.0 * Math.PI * Math.pow(r, 3);
	}

	private static double surfaceArea(double r) {
		return 4.0 * Math.PI * Math.pow(r, 2);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		BufferedReader console = new BufferedReader(new InputStreamReader(
				System.in));
		boolean radiusok = false;

		double radius = 0;
		while (!radiusok) {
			System.out.print("Enter the radius: ");

			try {
				radius = Double.parseDouble(console.readLine());
				radiusok = true;
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		DecimalFormat f3 = new DecimalFormat("0.000");
		System.out.println();
		System.out.println("Radius = " + f3.format(radius));
		System.out.println("Volume = " + f3.format(volume(radius)));
		System.out.println("Surface area = " + f3.format(surfaceArea(radius)));
	}

}
